$(function(){
	var admin_id = getCookie('admin_id');
	if(!admin_id){
		window.location.replace('login.html');
	}
	var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, {
        color: '#1AB394'
    });
	//提交表单
   $("#submit").click(function(){
   		 if($("#signupForm").valid()){
          var query = $("#signupForm").serialize();
          ajax_post(ApiUrl + "/setting","config.html",query);
    	}
   });
   var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
            storeName: {
                required: true
            },
            shopkeeper: {
                required: true
            },
            phone: {
                required: true,
                number : true,
                rangelength:[11,11]
            },
            tel: {
                required: true,
                number : true,
            },
            address: {
                required: true
            }
        },
        messages: {
            storeName: {
                required: icon+ "请输入门店名称！"
            },
            shopkeeper: {
                required: icon+ "请输入门店店长！"
            },
            phone: {
                required: icon+ "请输入手机号！",
                number :  icon+"手机号只能是数字" ,
                rangelength: icon+"请输入正确的手机号"
            },
            tel: {
                required: icon+ "请输入座机号！",
                number :  icon+"座机号只能是数字" 
            },
            address: {
                required: icon+ "请输入门店地址！"
            }
        }
    });
});